﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DTO = Mbr.Reviews.Core.Contracts.DTO;

namespace Mbr.Reviews.Core.DtoMappers
{
    internal class ProductMapper
    {
        public static Product Map(DTO.Product dto)
        {
            return new Product(dto.Id, dto.Name, dto.Uri, dto.Tags) 
            { 
                Description = dto.Description
            };
        }

        public static IEnumerable<Product> Map(IEnumerable<DTO.Product> dtoCollection)
        {
            return dtoCollection.Select(d => Map(d)).ToArray();
        }

    }

    internal static class Extensions
    {
        public static Product ToDomain(this DTO.Product dto)
        {
            return ProductMapper.Map(dto);
        }

        public static IEnumerable<Product> ToDomain(this IEnumerable<DTO.Product> dtoCollection)
        {
            return ProductMapper.Map(dtoCollection);
        }
    }
}
